import { createApp } from 'vue'
import { createPinia } from 'pinia'  // 凤梨

// 引入Vue组件库 ７０％的组件有组件库提供了
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// console.log(ElementPlusIconsVue, '//////');
// import * as DemoData from './test'
// import { a, c } from './test';
// console.log( a, c);
import {
    ElButton,
    ElForm,
    ElFormItem,
    ElInput,
    ElCheckbox,
    ElLink,
    ElIcon,
    ElAvatar,
    ElDropdown,
    ElDropdownMenu,
    ElDropdownItem,
    ElMenu,
    ElSubMenu,
    ElMenuItem,

} from 'element-plus';
// 组件库依赖的样式
import 'element-plus/dist/index.css';
import './assets/styles/variable.css'
import router from './router';
import App from './App.vue'

const app = createApp(App)

for ( const [key, component ] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}

app
    .use(createPinia())
    .use(router)
    .use(ElButton)
    .use(ElForm)
    .use(ElFormItem)
    .use(ElInput)
    .use(ElCheckbox)
    .use(ElLink)
    .use(ElIcon)
    .use(ElAvatar)
    .use(ElDropdown)
    .use(ElDropdownMenu)
    .use(ElDropdownItem)
    .use(ElMenu)
    .use(ElSubMenu)
    .use(ElMenuItem)
// 自定义指令
import { usePermissStore } from './store/permiss';

const permissStore = usePermissStore();

app.directive('permiss', {
    // v-if  v-show   el dom, binding 绑定的属性
    mounted(el, binding) {
        if (binding.value &&
            !permissStore.key.includes(String(binding.value))
        ){
            el['hidden'] = true
        }
    }
})

app
    .mount('#app')
